import "./index.less";

export default React.createClass({
    getDefaultProps(){
        return {
            icon: false,
        };
    },
    componentDidMount(){
        // window.addEventListener('click')
    },
    getInitialState() {
        return {
            checked: '',
            onSelect: function (item) {
            }
        };
    },
    onclick(){
        this.setState({checked: this.state.checked ? '' : 'open'});
    },
    render(){
        const self = this;
        return (
            <div className={'select-photo menu-drop-down select  ' + this.state.checked}
                 onClick={this.onclick}
                 onBlur={()=> {
                     _.debounce(item=> {
                         self.setState({checked: ''});
                     }, 300)
                 }}
            >
                <a href="javascript:void(0);"
                   className="menu-label">
                    {this.props.img && <img src={this.props.img}
                                            alt=""
                                            style={{height: '26px', marginRight: 5, borderRadius: 3}}
                    />}
                    <span style={{float: 'none'}}>{this.props.label || '默认'}</span>
                    <span className="caret" style={{top: 0}}></span>
                </a>
                <ul className="pic-list dropdown-menu">
                    {this.props.children}
                </ul>
            </div>
        )
    }
})